package leecode

func wateringPlants(plants []int, capacity int) int {
	temp := capacity
	var result int
	for i := 0; i < len(plants); i++ {
		if capacity >= plants[i] {
			result++
		} else {
			result += i*2 + 1
			capacity = temp
		}
		capacity = capacity - plants[i]
	}
	return result
}
